<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org" >
    
    <head>
        <meta charset="UTF-8">
        <title>欢迎页面-X-admin2.2</title>
        <header th:replace="header::html"></header>
        <link rel="stylesheet" th:href="@{/ztree/zTreeStyle/zTreeStyle.css}" />
        <link rel="stylesheet" th:href="@{/ztree/demo.css}" >
    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                  <div class="layui-form-item">
                      <label for="name" class="layui-form-label">
                          <span class="x-red">*</span>角色名
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="name" name="name" required="" th:value="${sysRole.name}" lay-verify="required"
                          autocomplete="off" class="layui-input">
                      </div>
                      <div class="layui-form-mid layui-word-aux">
                          <span class="x-red">*</span>
                      </div>
                  </div>
                  <div class="layui-form-item">
                      <label for="description" class="layui-form-label">
                          <span class="x-red">*</span>描述
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="description" name="description" required="" lay-verify="description" th:value="${sysRole.description}"
                          autocomplete="off" class="layui-input">
                      </div>
                      <div class="layui-form-mid layui-word-aux">
                          <span class="x-red">*</span>
                      </div>
                  </div>
                  <div class="layui-form-item">
                      <label class="col-md-2 control-label layui-form-label">权限</label>
                      <div class="col-md-10">
                          <ul id="treeDemo" class="ztree"></ul>
                      </div>
                  </div>
                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label">
                      </label>
                      <button  class="layui-btn" lay-filter="add" lay-submit="">
                          增加
                      </button>
                  </div>
              </form>
            </div>
        </div>
        <script>layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;


                //监听提交
                form.on('submit(add)',
                function(data) {
                    console.log(data.field);
                    $.ajax({
                        url:'/sys-role/add',
                        type:'POST',
                        data:data.field,
                        dataType:'json',
                        success:function (res) {
                            alert('添加成功！')
                        }
                    })
                    //发异步，把数据提交给
                    layer.alert("增加成功", {
                        icon: 6
                    },
                    function() {
                        //关闭当前frame
                        xadmin.close();

                        // 可以对父窗口进行刷新 
                        xadmin.father_reload();
                    });
                    return false;
                });
            });
            $.fn.zTree.init($("#treeDemo"),getSettting(),getMenuTree());
        </script>
        <script>var _hmt = _hmt || []; (function() {
                var hm = document.createElement("script");
                hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();</script>
    </body>

<style>
    div#rMenu {position:absolute; visibility:hidden; top:0; background-color: #555;text-align: left;padding: 2px;}
    div#rMenu ul li{
        margin: 1px 0;
        padding: 0 5px;
        cursor: pointer;
        list-style: none outside none;
        background-color: #DFDFDF;
    }
</style>

</html>
